package cn.edu.scau.cmi.tancuier.client;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;

public class ComprehensionClient extends Application{

	public static void main(String[] args) {
		Application.launch(args);
	}

	@Override
	public void start(Stage primaryStage) throws Exception {
		primaryStage.setTitle("Comprehension");
		
		FlowPane flowPane = new FlowPane();
		flowPane.setPadding(new Insets(10, 20, 10, 20));
		flowPane.setHgap(5);
		flowPane.setVgap(5);
		
		Label ID = new Label("学号： 201727010316");
		ID.setPrefWidth(250);
		flowPane.getChildren().add(ID);
		
		Label name = new Label("姓名： 谭翠儿");
		name.setPrefWidth(250);
		flowPane.getChildren().add(name);
		
		//InterProgramming
		Button interProgramming = new Button("实验一：接口编程");
		interProgramming.setPrefWidth(170);
		flowPane.getChildren().add(interProgramming);
		interProgramming.setOnAction(new EventHandler<ActionEvent>() {
			@Override
			public void handle(ActionEvent event) {
				InterProgrammingClient client = new InterProgrammingClient();
				try {
					client.start(new Stage());
				}
				catch(Exception e) {
					e.printStackTrace();
				}
			}
		});
		//Singleton
		Button singleton = new Button("实验二：单例模式");
		singleton.setPrefWidth(170);
		flowPane.getChildren().add(singleton);
		singleton.setOnAction(new EventHandler<ActionEvent>() {
			@Override
			public void handle(ActionEvent event) {
				SingletonClient client = new SingletonClient();
				try {
					client.start(new Stage());
				}
				catch(Exception e) {
					e.printStackTrace();
				}
			}
		});
		//Mutiton
		Button mutiton = new Button("实验二：多例模式");
		mutiton.setPrefWidth(170);
		flowPane.getChildren().add(mutiton);
		mutiton.setOnAction(new EventHandler<ActionEvent>(){
			@Override
			public void handle(ActionEvent event) {
				MutitonClient client = new MutitonClient();
				try {
					client.start(new Stage());
				}
				catch(Exception e) {
					e.printStackTrace();
				}
			}
		});
		//SimpleFactory
		Button simpleFactory = new Button("实验三：简单工厂");
		simpleFactory.setPrefWidth(170);
		flowPane.getChildren().add(simpleFactory);
		simpleFactory.setOnAction(new EventHandler<ActionEvent>(){
			@Override
			public void handle(ActionEvent event) {
				SimpleFactoryClient client = new SimpleFactoryClient();
				try {
					client.start(new Stage());
				}
				catch(Exception e) {
					e.printStackTrace();
				}
			}
		});
		//Factory
		Button factory = new Button("实验三：工厂模式");
		factory.setPrefWidth(170);
		flowPane.getChildren().add(factory);
		factory.setOnAction(new EventHandler<ActionEvent>(){
			@Override
			public void handle(ActionEvent event) {
				FactoryClient client = new FactoryClient();
				try {
					client.start(new Stage());
				}
				catch(Exception e) {
					e.printStackTrace();
				}
			}
		});
		//AbstractFactory
		Button abstractFactory = new Button("实验三：抽象工厂");
		abstractFactory.setPrefWidth(170);
		flowPane.getChildren().add(abstractFactory);
		abstractFactory.setOnAction(new EventHandler<ActionEvent>(){
			@Override
			public void handle(ActionEvent event) {
				AbstractFactoryClient client = new AbstractFactoryClient();
				try {
					client.start(new Stage());
				}
				catch(Exception e) {
					e.printStackTrace();
				}
			}
		});
		//AdapterOfClass
		Button adapterOfClass = new Button("实验四：适配器（类）");
		adapterOfClass.setPrefWidth(170);
		flowPane.getChildren().add(adapterOfClass);
		adapterOfClass.setOnAction(new EventHandler<ActionEvent>(){
			@Override
			public void handle(ActionEvent event) {
				AdapterOfClassClient client = new AdapterOfClassClient();
				try {
					client.start(new Stage());
				}
				catch(Exception e) {
					e.printStackTrace();
				}
			}
		});
		//AdapterOfObject
		Button adapterOfObject = new Button("实验四：适配器（对象）");
		adapterOfObject.setPrefWidth(170);
		flowPane.getChildren().add(adapterOfObject);
		adapterOfObject.setOnAction(new EventHandler<ActionEvent>(){
			@Override
			public void handle(ActionEvent event) {
				AdapterOfObjectClient client = new AdapterOfObjectClient();
				try {
					client.start(new Stage());
				}
				catch(Exception e) {
					e.printStackTrace();
				}
			}
		});
		//ConsistentComposite
		Button consistentComposite = new Button("实验五：一致性组合模式");
		consistentComposite.setPrefWidth(170);
		flowPane.getChildren().add(consistentComposite);
		consistentComposite.setOnAction(new EventHandler<ActionEvent>(){
			@Override
			public void handle(ActionEvent event) {
				ConsistentCompositeClient client = new ConsistentCompositeClient();
				try {
					client.start(new Stage());
				}
				catch(Exception e) {
					e.printStackTrace();
				}
			}
		});
		//SafeComposite
		Button safeComposite = new Button("实验五：安全性组合模式");
		safeComposite.setPrefWidth(170);
		flowPane.getChildren().add(safeComposite);
		safeComposite.setOnAction(new EventHandler<ActionEvent>(){
			@Override
			public void handle(ActionEvent event) {
				SafeCompositeClient client = new SafeCompositeClient();
				try {
					client.start(new Stage());
				}
				catch(Exception e) {
					e.printStackTrace();
				}
			}
		});
		//Hibernate
		Button hibernate = new Button("实验六：Hibernate框架");
		hibernate.setPrefWidth(170);
		flowPane.getChildren().add(hibernate);
		hibernate.setOnAction(new EventHandler<ActionEvent>(){
			@Override
			public void handle(ActionEvent event) {
				HibernateClient client = new HibernateClient();
				try {
					client.start(new Stage());
				}
				catch(Exception e) {
					e.printStackTrace();
				}
			}
		});
		//Spring
		Button spring = new Button("实验七：Spring框架");
		spring.setPrefWidth(170);
		flowPane.getChildren().add(spring);
		spring.setOnAction(new EventHandler<ActionEvent>(){
			@Override
			public void handle(ActionEvent event) {
				SpringClient client = new SpringClient();
				try {
					client.start(new Stage());
				}
				catch(Exception e) {
					e.printStackTrace();
				}
			}
		});
		
		Scene scene = new Scene(flowPane, 250, 450);
		primaryStage.setScene(scene);
		primaryStage.show();
	}

}
